package dk.contix.eclipse.hudson.views;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.IStructuredSelection;

import dk.contix.eclipse.hudson.Job;

public final class ViewConsoleAction extends Action {
	private final HudsonView hudsonView;

	public ViewConsoleAction(HudsonView hudsonView) {
		this.hudsonView = hudsonView;
	}

	@Override
	public void run() {
		IStructuredSelection sel = (IStructuredSelection) hudsonView.viewer.getSelection();
		Job j = (Job) sel.getFirstElement();

		String path = String.format("job/%s/%s/consoleText", j.getName(), j.getLastBuild().getNumber());
		hudsonView.openBrowser(path, "Console output");
	}
}
